<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0,minimum-scale=1.0">
        <title>
            授权公司列表
        </title>
        <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    
        </script>
        <!-- 引入 layui.css -->
    <link href="./css/layui.css" rel="stylesheet" />

    <!-- 引入 layui.js -->
    <script src="./js/layui.js"></script>
    <script src="./js/utils.js"></script>
    <script src="./js/constant.js" ></script>
    <script src="./js/data.js"></script>
    <script src="./js/userAuth.js"></script>
    <script src="./js/request.js"></script>
        <script type="text/javascript">

            function onClick(data){
                // alert(JSON.stringify(data));
            }

            function onClickBack(){
                history.back()
            }
            function toCreate(){
                location.href=AUTH_COMPANY_PAGE;
            }
            
            function loadData(){
                var index = layer.load()
                $.ajax({
                    url  :REQUEST_URL,
                    type : "json",
                    method:"post",
                    contentType:"application/json",
                    data: JSON.stringify({action : "GetuUerAuthCompanyList"}),
                    headers:REQUEST_HEADERS(),
                    success:function(r,t,x){

                        

                        layer.close(index)
                        const res = responseHandler(r,t,x);
                        const data = res.list[0].Rows;
                        $("#list-container *").remove();
                    data.forEach(item=>{
                        const ele = `<div id="id_${item.KSBH}" class="row" >
                <div class="row-item row-item-line">
                    <div>公司编号</div>
                    <div>${item.KSBH}</div>
                </div>
                <div class="row-item row-item-line">
                    <div>公司名称</div>
                    <div>${item.KSMC}</div>
                </div>
                <div class="row-item row-item-line">
                    <div>授权状态</div>
                    <div>${item.SQZT}</div>
                </div>
                <div class="row-item ">
                    <div>是否默认</div>
                    <div>${item.isDefault=='Y' ? "是":"否"}</div>
                </div>

            </div>`
                        $("#list-container").append(ele);
                        $("#id_"+item.KSBH  ).click(function(){
                            console.log($(this),item)
                            location.href="authCompany.html?companyNumber="+item.KSBH;
                            
                        })
                    })
                    },
                    err:function(xhr,status,p3,p4){

                    }
                })
                
                
            }

            $(document).ready(()=>{
                // init();
                loadData();
            })


        </script>
        <style>
            body{
                background-color: rgb(240,240,240);
            }
            #list-container {
                padding: 10px;
                
            }
            .row {
                background-color: white;
                margin-bottom: 10px;
                
            }
            .row-item {
                display: flex;
                flex-direction: row;
                justify-content: space-between;
                padding: 10px;
                align-items: center;

            }
            .row-item-line {
                border-bottom: 1px solid rgb(244,244,244);
            }
        </style>
    </head>
    <body>
        <!-- 企业logo -->
        <div style="padding: 20px;background-color: white;">
        <img src="./static/tongkun_logo.png" style="width: 100%;"/>
        </div>
        <!-- 数据列表 -->
        <div id="list-container">
            <div class="row" >
                <div class="row-item row-item-line">
                    <div>公司编号</div>
                    <div>公司编号</div>
                </div>
                <div class="row-item row-item-line">
                    <div>公司编号</div>
                    <div>公司编号</div>
                </div>
                <div class="row-item row-item-line">
                    <div>公司编号</div>
                    <div>公司编号</div>
                </div>
                <div class="row-item ">
                    <div>公司编号</div>
                    <div>公司编号</div>
                </div>

            </div>
        </div>
        <!-- 底部按钮 -->
        <div style="padding: 0px 20px 40px 20px;display: flex;flex-direction: row;justify-content: space-between;align-items: center;">
            <div onclick="onClickBack()" style="text-align: center;line-height: 40px;width: 150px;height: 40px;border-radius: 20px;background-color: white;border: 1px solid rgb(229,86,77);color: rgb(229,86,77);">
                    返回
            </div>
            <div onclick="toCreate()" style="text-align: center;line-height: 40px;width: 150px;height: 40px;border-radius: 20px;background-color: rgb(229,86,77);border: 1px solid rgb(229,86,77);color: white;">
                
                新建授权
                    
            </div>
        </div>

    </body>
</html>